package thread;

/**
 * @Author liangzai
 * @Description:
 */

class SingletonLazy{
    private volatile static SingletonLazy instance = null;
    public static Object locker = new Object();

    public static SingletonLazy getInstance(){
        synchronized (locker) {
            if (instance == null) {
                instance = new SingletonLazy();
            }
        }
        return instance;
    }

    private SingletonLazy(){

    }
}

public class Demo2 {
    public static void main(String[] args) {
        SingletonLazy t1 = SingletonLazy.getInstance();
        SingletonLazy t2 = SingletonLazy.getInstance();

        System.out.println(t1 == t2);
    }
}
